import org.testng.annotations.Test;
import utils.utils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

public class Driuid_user {
    @Test
    public void textDML01(){
        PreparedStatement preparedStatement=null;
        Connection connection=null;
        ResultSet resultSet=null;
        ArrayList<emp> list=new ArrayList<>();
        String url="select * from  db_1";
        try {
            connection = Driuid.getconnection();
            preparedStatement=connection.prepareStatement(url);
            resultSet = preparedStatement.executeQuery();
            while (resultSet.next()){
                String idname = resultSet.getString("idname");
                int id=resultSet.getInt("id");
                int sal=resultSet.getInt("sal");
                list.add(new emp(idname,id,sal));
            }
            for (emp e:list
                 ) {
                System.out.println(e);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            Driuid.close(resultSet,preparedStatement,connection);
        }
    }
}
